package drugdealer.gui;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import drugdealer.negocio.Facade;
import drugdealer.negocio.IFacade;
import drugdealer.gui.components.SolicitacaoExternaComposite;

public class AdminApp extends Composite {
	protected IFacade facade;
	private SolicitacaoExternaComposite solExtComp;
	
	public AdminApp(Composite parent) {
		super(parent, SWT.NONE);
		this.setLayout(parent.getLayout());

		this.facade = (IFacade) new Facade();
		
		this.solExtComp = new SolicitacaoExternaComposite(this, this.facade);
		this.solExtComp.setTransacoesChegada(
				this.facade.getTransacoesSaidaAbertas());
		this.solExtComp.setPedidos(this.facade.getPedidos());
	}

	//-------------------------------------------------------------------------
	public static void main(String args[]) {
		Display display = new Display ();
		final Shell shell = new Shell (display);
		GridLayout layout = new GridLayout (1, true);
		layout.marginHeight = layout.marginWidth = 0;
		shell.setLayout (layout);
		
		shell.setLayout(new FillLayout());
		
		shell.setText("DrugDealer - Administrador");
		shell.setImage(new Image(display, "./imgs/drugdealer.png"));
		
		new AdminApp(shell);
		
		shell.setMinimumSize(800, 380);
		shell.setLocation(100, 20);
		shell.pack ();
		shell.open ();
		
		while (!shell.isDisposed ())
			if (!display.readAndDispatch ()) display.sleep ();
		
		display.dispose ();
	}
}
